package com.team1160.scouting.frontend;

import java.awt.HeadlessException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.team1160.scouting.panels.InitialPanel;
import com.team1160.scouting.panels.MatchPanel;
import com.team1160.scouting.panels.MenuPanel;
import com.team1160.scouting.resourcePackets.CardLayoutPacket;

/**
 * The actual JFrame that contains the application
 * @author Saketh Kasibatla
 */
public class ScoutingAppWindow extends JFrame{
    /**
     * the splash pane which displays the FIRST logo and 1160 logo
     */
    private InitialPanel splash;

    /**
     * the main menu which allows you to go to the match, pit, and data sections of the app.
     */
    private MenuPanel menu;

    /**
     * the part of the app which is dedicated to match scouting.
     */
    private MatchPanel match;

    /**
     * Contains the card layout and its parent.
     */
    private CardLayoutPacket layout;

    /**
     * the panel upon which the cardlayout will change panels.
     */
    private JPanel cards;

    /**
     * makes a new window
     * @param title the title of the window
     * @throws HeadlessException
     */
    public ScoutingAppWindow(String title) throws HeadlessException {
        super(title);
        this.cards=new JPanel();
        layout = new CardLayoutPacket(cards);
        cards.setLayout(this.layout.getLayout());
        splash = new InitialPanel(layout);
        splash.setOpaque(true);
        menu = new MenuPanel(layout);
        try {
            match = new MatchPanel(layout);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        cards.add(splash,"splashscreen");
        cards.add(menu,"menu");
        cards.add(match,"match");
        this.add(cards);


        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(820,610);
        this.setVisible(true);
    }

    /**
     * creates a new window with the default title of 1160 Scouting App
     * @throws HeadlessException
     */
    public ScoutingAppWindow() throws HeadlessException {
        new ScoutingAppWindow("1160 Scouting App");
    }


}
